package cn.edu.swufe.surverpark.struts2.interceptor;



import java.util.Map;

import org.apache.struts2.ServletActionContext;

import cn.edu.swufe.surverpark.model.Right;
import cn.edu.swufe.surverpark.model.User;
import cn.edu.swufe.surverpark.struts2.action.BaseAction;
import cn.edu.swufe.surverpark.util.ValidateUtil;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 *@author 陈龙 E-mail:529914446@qq.com
 *@version创建时间:2015年4月30日下午2:28:05
 *类说明
 */
public class RightFilterInterceptor implements Interceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2149824131891115564L;

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		BaseAction action = (BaseAction) arg0.getAction();
		ActionProxy proxy = arg0.getProxy();
		String ns = proxy.getNamespace();
		String actionName = proxy.getActionName();
		if(ValidateUtil.hasRight(ServletActionContext.getRequest(), ns, actionName,action))
			return arg0.invoke();
		return "login";
	}

}

